import 'package:flutter/material.dart';
import 'package:keframe/frame_separate_widget.dart';
import 'package:keframe/size_cache_widget.dart';

class FrameSeparate extends StatelessWidget {
  /// 子类
  final Widget child;

  /// 占位控件
  final Widget? placeHolder;

  /// 标识其自己的ID，用于存储大小信息的场景
  final int? index;

  /// 需要需要对应的缓存控件包裹
  final bool needSizeCache;

  /// 预先知道一个页面一屏幕有多少个元素的时候传递
  final int estimateCount;

  const FrameSeparate({
    Key? key,
    this.placeHolder,
    this.index,
    required this.child,
    this.needSizeCache = false,
    this.estimateCount = 0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final FrameSeparateWidget childWidget = FrameSeparateWidget(index: index, placeHolder: placeHolder, child: child);
    if (needSizeCache) {
      return SizeCacheWidget(child: childWidget, estimateCount: estimateCount);
    }
    return childWidget;
  }
}
